package com.onlineclass.classserver.controller;

import com.onlineclass.beas.Course;
import com.onlineclass.beas.ResultObject;
import com.onlineclass.classserver.service.Irecommendservice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/recommend")
@Slf4j
public class Recommendcontroller {

    @Autowired
    Irecommendservice irecommendservice;

    @RequestMapping("/getrecommend")
    public ResultObject getRecommendedcourses(){
        ResultObject o = new ResultObject();
        List<Course> courses = irecommendservice.selectrecommendedcourses();
        if (courses == null) {
            o.setStatus(404);
            o.setInfo("查寻失败");

            return o;
        } else {
            o.setStatus(1);
            o.setInfo("查寻成功");
            o.setData(courses);
            log.info(String.valueOf(courses));
            return o;
        }
    }

}
